/* to be used in conjunction with Program 3-4 */

void keypad_init(void);
unsigned char keypad_getchar(void);

int main(void)
{
    unsigned char key;
    
    keypad_init();
    LCD_init();
    LCD_data('>');

    while(1)
    {
        /* wait until a key is pressed */
        do{
            key = keypad_getkey();
            delayMs(20);   /* debounce the key contact */
        while(keypad_getkey() != key);

        LCD_data(key);      /* display the key label */

        /* wait until the previous key is released */
        do{
            while(keypad_getkey() != 0); 
            delayMs(20);        /* wait to debounce */
        }while(keypad_getkey() != 0);
    }
}